import com.fyk.entity.Book;
import com.fyk.entity.User;
import com.fyk.mapper.BookMapper;
import com.fyk.mapper.UserBookMapper;
import com.fyk.mapper.UserMapper;
import com.fyk.mapper.UserRoleMapper;
import com.fyk.service.BookService;
import com.fyk.service.Impl.BookServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author qazws
 * @Date 2022/8/19 10:30
 * @Version 1.0
 */

@RunWith(SpringJUnit4ClassRunner.class)
/*@ContextConfiguration(locations = "classpath:application.xml")*/
@ContextConfiguration(locations = "classpath:spring-mapper.xml")

public class BookTets {


    @Autowired
    private UserRoleMapper userRole;
    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserBookMapper userBookMapper;

    @Autowired
    private BookMapper bookMapper;

   /* @Autowired
    private BookService bookService;*/



    @Test
    public void bookTest1(){
        System.out.println(userRole.selectRoleByUsername(""));
    }
    @Test
    public void bookTest2(){
        User user = new User();
        user.setUserId(3);
        user.setName("aa");
        System.out.println(userMapper.updateUser(user));
    }
    @Test
    public void bookTest3(){
        userBookMapper.insertUserAndBook(2,3);
    }

    @Test
    public void bookTest5(){
        Book book = new Book();
        book.setBookNums(0);
        book.setBookId(3);
        System.out.println(book.getBookNums());
        System.out.println(bookMapper.updateBook(book));
    }

    @Test
    public void bookTest(){
        userBookMapper.deleteBook(1,2);
        Book book = bookMapper.selectBookByBookId(2);
        book.setBookNums(book.getBookNums() + 1);
        bookMapper.updateBook(book);
    }
    @Test
    public void bookTest13(){
        User user = new User();
        user.setDeleted(0);

        userMapper.selectUserByUserIdOrUsername(user);
    }

    @Test
    public void bookTest113(){
        List<String> list = new ArrayList<>();
        list.add("104");
        userMapper.returnAllUser(list);
    }






}
